package com.zeny.express.framework.webapp.grid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.zeny.express.framework.shared.domain.User;
import com.zeny.express.framework.webapp.action.BaseAction;

@SuppressWarnings("serial")
@Controller
@Scope("prototype")
public class GridColumnAction extends BaseAction {

	private String gridId;

	private String content;

	@Autowired
	private GridColumnService gridColumnService;

	public String query() {

		User user = this.getCurrentUser();

		GridColumnEntity entity = gridColumnService.query(gridId, user.getUserCode());
		
		if (entity != null) {
			result.put("content", entity.getContent());
		}

		return SUCCESS;
	}

	public String save() {

		User user = this.getCurrentUser();

		gridColumnService.save(gridId, user.getUserCode(), content);

		return SUCCESS;
	}

	public String delete() {

		User user = this.getCurrentUser();

		gridColumnService.delete(gridId, user.getUserCode());

		return SUCCESS;
	}

	/**
	 * @return gridId
	 */
	public String getGridId() {
		return gridId;
	}

	/**
	 * @param gridId
	 */
	public void setGridId(String gridId) {
		this.gridId = gridId;
	}

	/**
	 * @return content
	 */
	public String getContent() {
		return content;
	}

	/**
	 * @param content
	 */
	public void setContent(String content) {
		this.content = content;
	}

}
